/***************************************************************************
 创建者: 华磊
 开始时间: 2019.3.12
 copyright: (C) 华友高科
 修改说明: (每次有修改就添加一条，带有 修改人，修改时间，修改描述)
 example (1) hualei 2017.5.8 类的具体实现代码编写

 ***************************************************************************
 *  @file x.h
 *  功能:
 *
 *                                                                         *
 ***************************************************************************/
#ifndef CANBUSBATTERY_H
#define CANBUSBATTERY_H
#include "MacroDefine/globalDefine.h"
#include <QString>
#include "ecattype.h"
#include "ethercatVendorId.h"
#include "canbusdevicedriver.h"
//class CanbusDeviceDriver;

class CanbusBattery
{
public:
    CanbusBattery(QString fileNameIn, int aliasIn, int busNumberIn, int deviceIdIn,
                  CanbusDeviceDriver *canbusDriverIn);
public:
    /**
     * @brief getBatteryInfo        获取电池信息
     * @param batteryInfoOut        电池组信息
     * @return                      success: 1  fail: 0/负数
     */
    int getBatteryInfo(BatteryInformation &batteryInfoOut);
    int updateData();
    int getDeviceAddressInfo(int& aliasOut, int& busNumberOut, int& deviceIdOut);
    bool isInitialOkStatus();

private:
    int initial(QString fileName);
    int processDataFrame();
    int processDataFrame_LiTonWei(const QQueue<FrameData> &bufferIn);

private:

    int alias;
    int busNumber;
    int deviceId;
    bool isInitialedOk;
    E_VENDOR_ID vendorId;
    CanbusDeviceDriver *canbusDriver;
    double batteryTempture;                     //电池组内部温度,unit is 摄氏度
    double batterySumVoltage;                   //电池组总电压,unit is V
    double batteryCurrentCurrency;              //电池组实时电流, unit is A
    double batteryLeftLightmodRatio;            //电池组相对剩余容量百分比，１表示充满
    double batteryLeftLightmodVolume;           //电池组剩余容量, unit is AH
    double batteryCycleNumber;                  //电池组循环次数
    double batteryDesignVolume;                 //电池组设计容量, unit is AH
    unsigned short manufatureData; //制造日期
    unsigned int balanceStatus;//均衡状态
    unsigned short errorStatus;//安全状态
    unsigned char softWareVersition;//软件版本
    unsigned char fet;//mos开关状态
    unsigned char batterySerialCount;//电池串数
    unsigned char ntcCount;//ntc温度传感器个数
};

#endif // CANBUSBATTERY_H
